package com.example.pojo;

import lombok.Data;

@Data
public class Response<T> {
    private int code;
    private String message;
    private T data;

    public static <T>Response<T> success(T data){
        return new Response<>(200, "操作成功", data);
    }

    public static <T>Response<T> success(){
        return new Response<>(200, "操作成功", null);
    }

    public static <T>Response<T> fail(String message){
        return new Response<>(201, message, null);
    }

    public static <T>Response<T> fail(){
        return new Response<>(201, "操作失败", null);
    }

    public Response(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Response(int code, String message) {
        this.code = code;
        this.message = message;
        this.data = null;
    }
}
